﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HashingDirectory
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }


        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Dispose();
            Application.Exit();
        }

        private void hToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Hashing hashForm = new Hashing();
            hashForm.MdiParent = this;

            windowToolStripMenuItem.DropDownItems.Add(hashForm.Text);
            hashForm.Show();

        }

        private void encryptFileFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormEncrypt encForm = new FormEncrypt();
            encForm.MdiParent = this;
            windowToolStripMenuItem.DropDownItems.Add(encForm.Text);
            encForm.Show();
        }

        private void decryptFileFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormDecrypt decForm = new FormDecrypt();
            decForm.MdiParent = this;
            windowToolStripMenuItem.DropDownItems.Add(decForm.Text);
            decForm.Show();
        }

        private void aboutMeToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            AboutBox1 AboutMe = new AboutBox1();
            AboutMe.MdiParent = this;
            windowToolStripMenuItem.DropDownItems.Add(AboutMe.Text);
            AboutMe.Show();
        }

        private void licenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Licence lForm = new Licence();
            lForm.MdiParent = this;
            windowToolStripMenuItem.DropDownItems.Add(lForm.Text);
            lForm.Show();
        }

        private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<Form> lst = new List<Form>();

            try
            {
                for (int i1 = 0; i1 < Application.OpenForms.Count; i1++)
                {
                    Form f = Application.OpenForms[i1];
                    if (f.IsMdiChild)
                        lst.Add(f);
                }
            }
            catch (Exception)
            {
                //This can change if they close/open a form while code is running. Just throw it away
            }

            while (lst.Count > 1)
            {

                Form f = lst[1];

                if (f.Name != "Default")
                {
                    f.Close();
                    f.Dispose();
                    lst.RemoveAt(1);
                    
                }
                

            }
            
            windowToolStripMenuItem.DropDownItems.Clear();
            windowToolStripMenuItem.DropDownItems.Add("Main Menu");


           
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            Default dForm = new Default();
            dForm.MdiParent = this;
            dForm.Size = new Size(685, 445);
            dForm.Show();
            windowToolStripMenuItem.DropDownItems.Add("Main Menu");

        }

 



    }
}
